package datacontainers;

import java.util.ArrayList;
import java.util.List;

public class AllDishes {

	List<Dish> dishes = new ArrayList<Dish>();

	/**
	 * return all dishes in selected category,by name filter
	 * 
	 * @param cat
	 * @param name
	 * @return
	 */
	public List<Dish> findByNameCategory(Category cat, String name) {
		List<Dish> list = new ArrayList<Dish>();

		for (Dish dish : dishes) {
			if (dish.getName().toUpperCase()
			        .matches(".*" + name.toUpperCase() + ".*")) {
				list.add(dish);
			}
		}
		return list;
	}

	public Dish findById(int id) {
		for (Dish dish : dishes) {
			if (dish.getId() == id) {
				return dish;
			}
		}
		return null;
	}

	public void addDish(Dish dish) {
		dishes.add(dish);
	}

}
